package com.project.class4_11.adpter;

public class Test {
    public static void main(String[] args) {
        Phone p = new Phone();
        p.takePicture();
        p.speak();
    }
}

interface ISpeak{
    public void speak();
}
interface ITakePic{
    public void takePicture();
}

class Tel implements ISpeak{
    public void speak(){
        System.out.println("通话");
    }
}
class  Camera implements ITakePic{
    public void takePicture(){
        System.out.println("照像");
    }
}

/**
 * 类适配器
 */
//class Phone extends Tel{
//    private Camera c = new Camera();
//    public void takePicture(){
//        c.takePicture();
//    }
//}

/**
 * 对象适配器
 */
class Phone implements ISpeak,ITakePic{
    private ISpeak s = new Tel();
    private ITakePic t = new Camera();

    @Override
    public void speak() {
        s.speak();
    }

    @Override
    public void takePicture() {
        t.takePicture();
    }
}